home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / JumpyText.pprx < prev    next >
Text File  |  1993-05-25  |  2KB  |  76 lines

  1. /* This Genie applies a random baseline shift to a selected block of text. Warnings: it is slow, it increases the length of the selected text by a factor of 8 or 9 (because of all the style codes needed), and it slows ProPage down to a crawl. So only do it at the end when you have got everything else right.
  2.  
  3. Written by Don Cox  © August 92  Bug-fix Dec 92  Not Public Domain. All rights reserved. */
  4.  
  5. trace n
  6. signal on error
  7. signal on syntax
  8. address command
  9. numeric digits 3  /* for the random numbers  */
  10. if word(ppm_GetState(), 1) ~= 3 then exit_msg("You must be in edit mode to use this Genie")
  11.  
  12. text = ppm_GetBlockText(0)
  13. if text = '' then exit_msg("No text selected")
  14.  
  15.  
  16. factor = ppm_GetUserText(8,"Maximum shift (points)")
  17. if factor = "" then exit_msg("Aborted by User")
  18. if ~(datatype(factor,n)) then exit_msg("Invalid entry")
  19.  
  20. if factor>600 then factor = 600
  21.  
  22.  
  23. call ppm_ShowStatus("  Processing text...")
  24.  
  25. /* Split into sections to avoid trouble with ARexx's limit of 64k on length of strings  */
  26. sections = (length(text)%2000)+1
  27. do i=1 to sections
  28.     texts.i.endofsection = 2000
  29.     if i = sections then texts.i.endofsection = length(text)//2000
  30.     texts.i.thisSection = substr(text, (2000*(i-1))+1, texts.i.endofsection)
  31.     end
  32.  
  33. do i = 1 to sections
  34.     position = 1
  35.     newtext = ""
  36.     do until position = texts.i.endofsection
  37.         randbase = "\ls<"||randu()*factor||">"
  38.         nextchar = substr(texts.i.thisSection, position, 1)
  39.         newtext = newtext||randbase||nextchar
  40.         position = position+1
  41.         end
  42.     if i = 1 then call ppm_SaveText("PPage:textfile.temp",newtext)
  43.     if i>1 then call ppm_SaveMoreText("PPage:textfile.temp",newtext)
  44. end
  45.  
  46. call ppm_ShowStatus("  Removing old text...")
  47. success = ppm_Cut()
  48. if success ~= 1 then exit_msg("Cut failed")
  49. call ppm_ShowStatus("  Inserting new text...")
  50. success = ppm_InsertFile("PPage:textfile.temp")
  51. if success~=1 then exit_msg("Failed inserting altered text")
  52.  
  53. "delete PPage:textfile.temp"
  54. call exit_msg()
  55. end
  56.  
  57.  
  58.  
  59. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  60.  
  61. error:
  62. syntax:
  63.     do
  64.     exit_msg("Genie failed due to error: "errortext(rc))
  65.     end
  66.  
  67. exit_msg:
  68.     do
  69.     parse arg message
  70.     if message ~= "" then
  71.     call ppm_Inform(1,message,"Resume")
  72.     call ppm_ClearStatus()
  73.     exit
  74.     end
  75.  
  76.